
package ro.qi.framework.sys.media.entities;

import java.util.Vector;

import ro.qi.framework.sys.entities.Entity;

/**
 * @deprecated
 * @author George Pogorelschi
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class MediaCategory extends Entity {

	public MediaCategory() {
		super();
		setMediaTableName(getTableName());
	}

	public MediaCategory(int id) {
		super();
		setMediaTableName(getTableName());
		setId(id);
		select();
	}

	public MediaCategory(String name) {
		super();
		setMediaTableName(getTableName());
		setName(name);
		select();
	}

	protected String getTableName() {return "";}

	public void setMediaTableName(String value) {setValue("mediaTableName", value);}
	public void setId(int value) {setValue("id", value);}
	public int getId() {return getIntValue("id");}
	public void setName(String value) {setValue("name", value);}
	public String getName() {return getStringValue("name");}
	public void setParentId(int value) {setValue("parentId", value);}
	public int getParentId() {return getIntValue("parentId");}

	public Vector getParents(int mediaCategoryId) {
		Vector ids = new Vector();
		MediaCategory mediaCategory = null;
		if( mediaCategoryId == getId() ) {
			mediaCategory = this;
		} else {
			mediaCategory = new MediaCategory(mediaCategoryId);
		}
		ids.add(new Integer(mediaCategoryId));
		while( mediaCategory.getParentId() != 0 ) {
			mediaCategory = new MediaCategory(mediaCategory.getParentId());
			ids.add(new Integer(mediaCategory.getId()));
		}
		return ids;
	}

}
